
function isInClick(dx,dy,obj){
    if(dx>obj.x  && dx<obj.x+ obj.width && dy<obj.y+obj.height &&  dy>obj.y){
        return true;
    }else{
        return false;
    }
}
export function bind_scence_event(scence){
    canvas.onclick=function(e){
        var dx = e.clientX-canvas.offsetLeft-1;
        var dy = e.clientY-canvas.offsetTop-1;
        for(let key in scence.btn){
            var btn = scence.btn[key]
            if(typeof btn.click === "function"){
                if(isInClick(dx,dy,btn)){
                    btn.click();
                }
            }
        }
    }
    if(typeof  scence.ontouchstart == "function"){
        canvas.ontouchstart = scence.ontouchstart
    }
}

